let snmp = require ("net-snmp");

//监控设备的ip
let session = snmp.createSession ("10.168.1.20", "public");

//snmp 协议 oid查询对节点的所有状态
let oid = "1.3.6.1.4.1.46861";

function doneCb (error) {
    if (error)
        console.error (error.toString ());
}

function feedCb (varbinds) {
    let result
    for (var i = 0; i < varbinds.length; i++) {
        if (snmp.isVarbindError (varbinds[i]))
            console.error (snmp.varbindError (varbinds[i]));
        else 
            console.log (varbinds[i].oid + "|" + varbinds[i].value);
    }
}


let maxRepetitions = 20;
// 这一步是为了前面打印是空 接住数据

// The maxRepetitions argument is optional, and will be ignored unless using
// SNMP verison 2c

//这一步是立马执行
// session.walk (oid, maxRepetitions, feedCb, doneCb);


// module.exports = {session,oid,maxRepetitions,feedCb,doneCb,result}


